using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;

namespace UIDesigner
{
  public enum ConstStyle { Win32, Google }
  public enum VariableStyle { Win32, Google, LowerCamel }

  public partial class オプション : Form
  {
    //静的変数・プロパティ----------------------▼
    //一応、デフォルトを用意
    private static ConstStyle s_IDConst = ConstStyle.Win32;
    private static ConstStyle s_Const = ConstStyle.Google;
    private static VariableStyle s_Variable = VariableStyle.Google;
    private static int s_StartID = 100;
    public static ConstStyle IDConstStyle
    {
      get
      {
        return s_IDConst;
      }
    }
    public static ConstStyle ConstStyle
    {
      get
      {
        return s_Const;
      }
    }
    public static VariableStyle VariableStyle
    {
      get
      {
        return s_Variable;
      }
    }
    public static int StartID
    {
      get
      {
        return s_StartID;
      }
    }
    //このやり方は醜いが、ファイルを１つ増やすなどするよりはいいだろう
    //静的変数・プロパティ----------------------▲

    public オプション()
    {
      InitializeComponent();
    }

    private void textStartID_KeyPress(object sender, KeyPressEventArgs e)
    {
      if ((e.KeyChar < '0' || e.KeyChar > '9') && e.KeyChar != '\b')
      {
        e.Handled = true;
      }
    }

    private ConstStyle GetIDConst()
    {
      if (this.radioIDWin32.Checked)
        return ConstStyle.Win32;
      if (this.radioIDGoogle.Checked)
        return ConstStyle.Google;
      Debug.Assert(false, "ID定数規則でチェックが見つかりません");
      return ConstStyle.Win32;
    }
    private ConstStyle GetConst()
    {
      if (this.radioConstWin32.Checked)
        return ConstStyle.Win32;
      if (this.radioConstGoogle.Checked)
        return ConstStyle.Google;
      Debug.Assert(false, "普通定数規則でチェックが見つかりません");
      return ConstStyle.Win32;
    }
    private VariableStyle GetVariable()
    {
      if (this.radioVariableWin32.Checked)
        return VariableStyle.Win32;
      if (this.radioVariableGoogle.Checked)
        return VariableStyle.Google;
      if (this.radioVariableLowerCamel.Checked)
        return VariableStyle.LowerCamel;
      Debug.Assert(false, "変数規則でチェックが見つかりません");
      return VariableStyle.Win32;
    }

    private void オプション_FormClosing(object sender, FormClosingEventArgs e)
    {
      this.Hide();
      if (e.CloseReason == CloseReason.UserClosing)
      {
        e.Cancel = true;
      }
    }

    private void buttonOK_Click(object sender, EventArgs e)
    {
      オプション.s_IDConst = this.GetIDConst();
      オプション.s_Const = this.GetConst();
      オプション.s_Variable = this.GetVariable();
      オプション.s_StartID = int.Parse(this.text開始ID.Text);
      this.Close();
    }

    private void buttonキャンセル_Click(object sender, EventArgs e)
    {
      this.Close();
    }
  }
}
